Skip to content

feat: 用户使用记录页面添加 API Key 使用统计图表#855

Closed
anzhen-tech wants to merge 4 commits intoWei-Shaw:mainfrom
anzhen-tech:main
Closed

feat: 用户使用记录页面添加 API Key 使用统计图表#855
anzhen-tech wants to merge 4 commits intoWei-Shaw:mainfrom
anzhen-tech:main

Conversation

@anzhen-tech
Copy link

新增可折叠的统计图表面板,包含:

  • 每个 API Key 的请求次数趋势折线图
  • 每个 API Key 的 Token 使用趋势折线图
  • 每个 API Key 的费用趋势折线图
  • 模型使用分布水平堆叠百分比条形图
  • 支持小时/日/月粒度切换

后端新增两个接口(不修改原有接口):

  • GET /api/v1/usage/dashboard/api-key-trend
  • GET /api/v1/usage/dashboard/api-key-model-distribution

新增可折叠的统计图表面板,包含:
- 每个 API Key 的请求次数趋势折线图
- 每个 API Key 的 Token 使用趋势折线图
- 每个 API Key 的费用趋势折线图
- 模型使用分布水平堆叠百分比条形图
- 支持小时/日/月粒度切换

后端新增两个接口(不修改原有接口):
- GET /api/v1/usage/dashboard/api-key-trend
- GET /api/v1/usage/dashboard/api-key-model-distribution
@anzhen-tech
Copy link
Author

新增针对API-Key的统计图表面板,包含:
每个 API Key 的请求次数趋势折线图
每个 API Key 的 Token 使用趋势折线图
每个 API Key 的费用趋势折线图
模型使用分布水平堆叠百分比条形图
支持小时/日/月粒度切换

anzhen-tech and others added 3 commits March 9, 2026 21:31
…t_test

stubUsageLogRepo was missing the GetAPIKeyModelDistribution method
added to UsageLogRepository interface, causing build failure.
- replace global unique constraint on api_keys.key with a partial unique index (WHERE deleted_at IS NULL)
- remove Unique() from ent schema field and regenerate ent/migrate/schema.go
- add migration 071 to drop the old constraint and create the partial index
- add integration test TestCreateAfterDelete_SameKey to cover the regression
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant